package com.ruoyi.electronicFence.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.electronicFence.domain.TEfAlarm;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.electronicFence.domain.TEfAlarmPerson;
import com.ruoyi.electronicFence.service.ITEfAlarmPersonService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报警数据与入侵人员关联管理
 *
 * @author sxygsj
 * @date 2024-05-29
 */
@RestController
@RequestMapping("/electronicFence/person")
public class TEfAlarmPersonController extends BaseController
{
    @Autowired
    private ITEfAlarmPersonService tEfAlarmPersonService;

    /**
     * 查询报警人员关联数据列表
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:person:list')")
    @GetMapping("/list")
    public TableDataInfo list(TEfAlarmPerson tEfAlarmPerson)
    {
        startPage();
        List<TEfAlarmPerson> list = tEfAlarmPersonService.selectTEfAlarmPersonList(tEfAlarmPerson);
        return getDataTable(list);
    }

    /**
     * 查询报警人员关联数据列表
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:person:list')")
    @PostMapping("/list2")
    public TableDataInfo list(@RequestBody List<TEfAlarm> list2)
    {
        startPage();
        List<TEfAlarmPerson> list = tEfAlarmPersonService.selectTEfAlarmPersonList2(list2);
        return getDataTable(list);
    }

    /**
     * 导出报警人员关联数据列表
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:person:export')")
    @Log(title = "报警人员关联数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TEfAlarmPerson tEfAlarmPerson)
    {
        List<TEfAlarmPerson> list = tEfAlarmPersonService.selectTEfAlarmPersonList(tEfAlarmPerson);
        ExcelUtil<TEfAlarmPerson> util = new ExcelUtil<TEfAlarmPerson>(TEfAlarmPerson.class);
        util.exportExcel(response, list, "报警人员关联数据数据");
    }

    /**
     * 获取报警人员关联数据详细信息
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:person:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tEfAlarmPersonService.selectTEfAlarmPersonById(id));
    }

    /**
     * 新增报警人员关联数据
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:person:add')")
    @Log(title = "报警人员关联数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TEfAlarmPerson tEfAlarmPerson)
    {
        return toAjax(tEfAlarmPersonService.insertTEfAlarmPerson(tEfAlarmPerson));
    }

    /**
     * 修改报警人员关联数据
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:person:edit')")
    @Log(title = "报警人员关联数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TEfAlarmPerson tEfAlarmPerson)
    {
        return toAjax(tEfAlarmPersonService.updateTEfAlarmPerson(tEfAlarmPerson));
    }

    /**
     * 删除报警人员关联数据
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:person:remove')")
    @Log(title = "报警人员关联数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tEfAlarmPersonService.deleteTEfAlarmPersonByIds(ids));
    }
}
